<template>
	<view>
		<image class="missback"
			src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/indexback.png" mode="widthFix">
		</image>
		<headers title="任务" showback="true" navBackcolor="#F9F8FA"></headers>
		<view class="mission">
			<!-- <nav-header title="任务" showback="true" navBackcolor="transparent"></nav-header> -->
			<view class="mission-banner">
				<image class="mission-banner-bg"
					src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/bg1.png"
					style="height: 322rpx;width: 686rpx;" mode="">
				</image>
				<view class="mission-banner-header u-flex u-row-between">
					<view class="mission-banner-header-left u-flex"
						@click="$Router.push('/pages/index/mission/candy-mine')">
						<view class="" style="margin-right:8rpx">
							全部喜糖
						</view>
						<image
							src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/warm.png"
							style="width: 32rpx;height: 32rpx;" mode="">
						</image>
					</view>
					<view class="mission-banner-header-right u-flex"
						@click="$Router.push('/pages/index/mission/candy-loss')">
						<view class="" style="margin-right:8rpx">
							喜糖明细
						</view>
						<image
							src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/chevron-right.png"
							style="width: 32rpx;height: 32rpx;" mode=""></image>
					</view>
				</view>
				<view class="mission-banner-main">
					<view class="mission-banner-main-num">
						{{ info.score }}
					</view>
					<image
						src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/gold-row.png"
						style="height: 2rpx;622rpx" mode=""></image>
					<view class="mission-banner-main-flex u-flex">
						<view class="mission-banner-main-flex-item">
							<view class="mission-banner-main-flex-item-title" style="color: #FFFCE5;">
								免费获得
							</view>
							<view class="mission-banner-main-flex-item-value" style="font-size: 24rpx;color: #FFF7B3;">
								{{ info.base_score }}
							</view>
						</view>
						<image
							src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/gold-col.png"
							style="width: 2rpx;height: 60rpx;" mode="">
						</image>
						<view class="mission-banner-main-flex-item">
							<view class="mission-banner-main-flex-item-title" style="color: #FFFCE5;">
								付费充值
							</view>
							<view class="mission-banner-main-flex-item-value" style="font-size: 24rpx;color: #FFF7B3;">
								0
							</view>
						</view>
						<image
							src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/gold-col.png"
							style="width: 2rpx;height: 60rpx;" mode="">
						</image>
						<view class="mission-banner-main-flex-item">
							<view class="mission-banner-main-flex-item-title" style="color: #FFFCE5;">
								任务奖励
							</view>
							<view class="mission-banner-main-flex-item-value" style="font-size: 24rpx;color: #FFF7B3;">
								0
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="mission-use">
				<view class="mission-use-title">
					喜糖用途
				</view>
				<view class="mission-use-main u-flex">
					<view class="mission-use-main-item">
						<image
							src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/candy-use1.png"
							mode=""></image>
						<view class="">
							申请认识
						</view>
					</view>
					<view class="mission-use-main-item">
						<image
							src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/candy-use2.png"
							mode=""></image>
						<view class="">
							CP盲盒
						</view>
					</view>
					<view class="mission-use-main-item">
						<image
							src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/candy-use3.png"
							mode=""></image>
						<view class="">
							上推荐墙
						</view>
					</view>
					<view class="mission-use-main-item">
						<image
							src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/candy-use4.png"
							mode=""></image>
						<view class="">
							解锁访客
						</view>
					</view>
					<view class="mission-use-main-item">
						<image
							src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/candy-use5.png"
							mode=""></image>
						<view class="">
							解锁粉丝
						</view>
					</view>
				</view>
			</view>
			<view class="mission-candy">
				<image src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/bg2.png"
					class="mission-candy-bg" style="height: 148rpx;width: 686rpx;" mode="">
				</image>
				<view class="mission-candy-main u-flex u-row-between">
					<view class="mission-candy-main-left">
						<view class="mission-candy-main-left-title">
							获取喜糖
						</view>
						<view class="mission-candy-main-left-dsc u-flex">
							<view class="">
								获取喜糖遇到困难？联系客服
							</view>
							<image style="height: 32rpx;width: 32rpx;"
								src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/chevron-right.png"
								mode=""></image>
						</view>
					</view>
					<view class="mission-candy-main-right">
						<view class="mission-candy-main-right-btn">
							立即进入
						</view>
					</view>
				</view>
			</view>
			<view class="mission-sign shadow-box">
				<view class="mission-sign-top"></view>
				<view class="mission-sign-title">
					签到
				</view>
				<view class="mission-sign-header u-flex">
					<view class="mission-sign-header-left">
						<image
							src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/mission-icon1.png"
							mode=""></image>
					</view>
					<view class="mission-sign-header-main">
						<view class="" style="font-size: 32rpx;font-weight: 400;">
							签到领奖励
						</view>
						<view class="" style="font-size: 24rpx;">
							已连续签到<span style="color: #FC2B4CFF;">1</span>天
						</view>
					</view>
					<view class="mission-sign-header-right" @click="signFun()">
						<image src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/btn/60x28.png"
							mode=""></image>
						<view class="mission-sign-header-right-con">
							签到
						</view>
					</view>
				</view>
				<view class="mission-sign-main u-flex">
					<!-- <view class="mission-sign-main-item mission-sign-main-down">
						<view class="mission-sign-main-item-top">
							<image src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/sign-check.png" mode=""></image>
						</view>
						<view class="mission-sign-main-item-down">
							已签
						</view>
					</view>
					<view class="mission-sign-main-item mission-sign-main-gift">
						<view class="mission-sign-main-item-top">
							<image src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/gift.png" style="width: 40rpx;height: 40rpx;"
								mode="">
							</image>
						</view>
						<view class="mission-sign-main-item-down">
							今天
						</view>
					</view> -->
					<view class="mission-sign-main-item mission-sign-main-plus" v-for="(item, index) in signlist">
						<view class="mission-sign-main-item-top" v-if="item.status == 1">
							<image
								src="https://zaiyiqi-1322608024.cos.ap-nanjing.myqcloud.com/static/img/index/mission/sign-check.png"
								mode=""></image>
						</view>
						<view class="mission-sign-main-item-top" v-if="item.status == 0 && item.is_day == 1">
							<image
								src="https://zyqyiq-1304758034.cos.ap-nanjing.myqcloud.com/static/img/index/mission/gift.png"
								style="width: 40rpx;height: 40rpx;" mode="">
							</image>
						</view>
						<view class="mission-sign-main-item-top" v-if="item.is_day == 0 && item.status == 0">
							+{{ item.num }}
						</view>
						<view class="mission-sign-main-item-down">
							{{ item.status == 1 ? '已签' : (item.status == 0 && item.is_day == 1) ? '今天' : ((index+1 )+'天')}}
						</view>
					</view>
				</view>
			</view>
			<view class="mission-main">
				<view class="mission-main-box shadow-box">
					<view class="mission-main-box-top"></view>
					<view class="mission-main-box-title">
						每日任务
					</view>
					<index-missionitem v-for="(item,index) in taskList" :key="index" :title="item.name"
						:point="item.reward" :type="item.is_finish" :icon="item.icon"></index-missionitem>
				</view>
				<view class="mission-main-box shadow-box">
					<view class="mission-main-box-top2"></view>
					<view class="mission-main-box-title">
						认证任务
					</view>
					<index-missionitem v-for="(item,index) in realList" :key="index" :title="item.name"
						:point="item.reward" :type="item.is_finish" :icon="item.icon"></index-missionitem>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
	// import navHeader from '../../../components/nav-header/nav-header.vue'
	import headers from '@/components/headers/index.vue'
	import indexMissionitem from '../../../components/index-missionitem/index-missionitem.vue'
	export default {
		// 组件名称
		name: 'demo',
		// 组件参数 接收来自父组件的数据
		props: {},
		// 局部注册的组件,import引入的组件需要注入到对象中才能使用
		components: {
			headers,
			// navHeader,
			indexMissionitem
		},
		// 组件状态值
		data() {
			return {
				taskList: [],
				realList: [],
				signlist: [{
						status: 0, // 0 未签 1 已签
						num: '10',
						is_day: 1, // 
					},
					{
						status: 0, // 0 未签 1 已签
						num: '20',
						is_day: 0, // 
					},
					{
						status: 0, // 0 未签 1 已签
						num: '30',
						is_day: 0, // 
					},
					{
						status: 0, // 0 未签 1 已签
						num: '40',
						is_day: 0, // 
					},
					{
						status: 0, // 0 未签 1 已签
						num: '50',
						is_day: 0, // 
					},
					{
						status: 0, // 0 未签 1 已签
						num: '60',
						is_day: 0, // 
					},
					{
						status: 0, // 0 未签 1 已签
						num: '70',
						is_day: 0, // 
					}
				],
				info: {}
			}
		},
		// 计算属性
		computed: {},
		// 侦听器
		watch: {},
		// 组件方法
		methods: {
			getInfo(){
				this.$http('user.info').then(res=>{
					console.log(res)
					this.info = res.data
					// this.$utils.setCache('userinfo',JSON.stringify(res.data))
				})
			},
			// 任务列表
			getTask() {
				this.$http('config.task', {
					token: uni.getStorageSync('token')
				}, '').then(res => {
					console.log(res)
					this.taskList = res.data.day
					this.realList = res.data.real
				})
			},
			// 签到
			signFun() {
				this.$http('config.sign', {
					token: uni.getStorageSync('token')
				}).then(res => {
					console.log(res)
					this.$utils.toast(res.info)
				})
			},
			signindex() {
				this.$http('config.signindex', {
					token: uni.getStorageSync('token')
				}).then(res => {
					console.log(res)
				})
			}
		},
		// 以下是生命周期钩子   注：没用到的钩子请自行删除
		/**
		 * 在实例初始化之后，组件属性计算之前，如data属性等
		 */
		beforeCreate() {},
		/**
		 * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
		 */
		created() {
			this.getTask()
			this.signindex()
			this.getInfo()
		},
		/**
		 * 在挂载开始之前被调用：相关的 render 函数首次被调用。
		 */
		beforeMount() {},
		/**
		 * el 被新创建的 vm.$ el 替换，并挂载到实例上去之后调用该钩子。
		 * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.$ el 也在文档内。
		 */
		mounted() {},
		/**
		 * 数据更新时调用，发生在虚拟 DOM 重新渲染和打补丁之前。
		 * 你可以在这个钩子中进一步地更改状态，这不会触发附加的重渲染过程。
		 */
		beforeUpdate() {},
		/**
		 * 由于数据更改导致的虚拟 DOM 重新渲染和打补丁，在这之后会调用该钩子。
		 * 当这个钩子被调用时，组件 DOM 已经更新，所以你现在可以执行依赖于 DOM 的操作。
		 */
		updated() {},
		/**
		 * keep-alive 组件激活时调用。 仅针对keep-alive 组件有效
		 */
		activated() {},
		/**
		 * keep-alive 组件停用时调用。 仅针对keep-alive 组件有效
		 */
		deactivated() {},
		/**
		 * 实例销毁之前调用。在这一步，实例仍然完全可用。
		 */
		beforeDestroy() {},
		/**
		 * Vue 实例销毁后调用。调用后，Vue 实例指示的所有东西都会解绑定，
		 * 所有的事件监听器会被移除，所有的子实例也会被销毁。
		 */
		destroyed() {}
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<!--使用了scoped属性之后，父组件的style样式将不会渗透到子组件中，-->
<!--然而子组件的根节点元素会同时被设置了scoped的父css样式和设置了scoped的子css样式影响，-->
<style scoped lang="scss">
	.mission {

		width: 100%;
		height: 100%;
		// background: linear-gradient(#F1EFFFFF 0%, #FFFFFF 40%, #F7F8FA 100%);
		// padding-top: $nav-top-height;
		background: #F9F8FA;
		padding-top: 32rpx;

		&-banner {
			width: 686rpx;
			height: 322rpx;
			border-radius: 16rpx 16rpx 16rpx 16rpx;
			position: relative;
			padding: 32rpx;
			font-size: 28rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			color: #FFFCE5;
			margin: 0 32rpx 32rpx;

			&-bg {
				position: absolute;
				top: 0;
				left: 0;
			}

			&-header {
				position: absolute;
				width: calc(100% - 64rpx);

				&-left {
					font-size: 28rpx;
					font-weight: 400;
					color: #FFFCE5;
				}

				&-right {
					font-size: 24rpx;
					font-weight: 400;
					color: #FFFCE5;
				}
			}

			&-main {

				position: absolute;
				width: calc(100% - 64rpx);
				top: 92rpx;

				&-num {
					font-size: 48rpx;
					font-family: DINPro-Bold, DINPro;
					font-weight: bold;
					color: #FFF7B3;
				}

				&-flex {
					// margin-top: 32rpx;
					margin-top: 20rpx;
					justify-content: center;

					&-item {
						text-align: center;
						width: 33%;

						&-title {}

						&-value {}
					}
				}
			}
		}

		&-use {
			padding: 32rpx;

			image {
				width: 76rpx;
				height: 76rpx;
			}

			&-title {
				font-size: 28rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #2E3033;
				margin-bottom: 40rpx;
			}

			&-main {
				font-size: 24rpx;
				font-family: PingFang SC-Medium, PingFang SC;
				font-weight: 500;
				color: #2E3033;

				&-item {
					text-align: center;
					flex: 1;
				}
			}
		}

		&-candy {
			height: 148rpx;
			// padding: 32rpx;
			display: flex;
			justify-content: center;
			// margin-bottom: 64rpx;
			margin-bottom: 40rpx;

			&-bg {
				position: absolute;
			}

			&-main {
				position: absolute;
				width: calc(100% - 64rpx);
				padding: 32rpx;

				&-left {
					&-title {
						font-size: 32rpx;
						font-family: YouSheBiaoTiHei-Regular, YouSheBiaoTiHei;
						font-weight: 400;
						color: #FFF7B3;
					}

					&-dsc {
						font-size: 24rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						margin-top: 12rpx;
						color: #FFFCE5;
					}
				}

				&-right {
					&-btn {
						width: 160rpx;
						height: 56rpx;
						background: #FFF7B3;
						border-radius: 34rpx;
						font-size: 24rpx;
						font-family: PingFang SC-Bold, PingFang SC;
						font-weight: bold;
						color: #31303E;
						line-height: 56rpx;
						text-align: center;
					}
				}
			}
		}

		&-sign {
			margin: 0 32rpx;
			padding: 32rpx 20rpx;
			position: relative;
			overflow: hidden;

			&-top {
				width: 208rpx;
				height: 208rpx;
				background: #E9E5FF;
				filter: blur(50px);
				position: absolute;
				top: -80rpx;
				left: -30rpx;
			}

			&-title {
				font-size: 28rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: 400;
				color: #2E3033;
				position: relative;
				z-index: 1;
			}

			&-header {
				margin-top: 30rpx;
				padding: 0rpx 0rpx 34rpx;
				position: relative;
				z-index: 1;

				&-left {
					width: 84rpx;

					image {
						height: 84rpx;
						width: 84rpx;
						display: block;
					}
				}

				&-main {
					margin: 0 20rpx;
					flex: 1;
					color: #2E3033;
				}

				&-right {
					width: 120rpx;
					height: 56rpx;
					position: relative;

					image {
						width: 120rpx;
						height: 56rpx;
						position: absolute;
						top: 0;
						left: 0;
					}

					&-con {
						width: 100%;
						height: 100%;
						text-align: center;
						line-height: 56rpx;
						font-size: 24rpx;
						font-weight: 400;
						color: #FCFDFF;
						position: relative;
					}
				}
			}

			&-main {
				&-item {
					text-align: center;
					width: 84rpx;
					margin-right: 8rpx;

					&-top {
						width: 84rpx;
						height: 100rpx;
						background: #F8F9FE;
						// line-height: 100rpx;
						border-radius: 8rpx 8rpx 8rpx 8rpx;

						font-size: 24rpx;
						font-weight: 400;
						color: #665747;
						display: flex;
						align-items: center;
						justify-content: center;

						image {
							width: 84rpx;
							height: 100rpx;
						}
					}

					&-down {
						margin-top: 8rpx;
						font-size: 20rpx;
						font-family: PingFang SC-Medium, PingFang SC;
						font-weight: 400;
						color: #4D4136;
					}
				}

				&-item:last-child {
					margin-right: 0 !important;
				}
			}
		}

		&-main {
			margin: 0 32rpx;

			&-box {
				padding: 32rpx;
				margin: 32rpx 0;
				position: relative;
				overflow: hidden;

				&-top {
					width: 208rpx;
					height: 208rpx;
					background: #E5F2FF;
					filter: blur(50px);
					position: absolute;
					top: -80rpx;
					left: -30rpx;
				}

				&-top2 {
					width: 208rpx;
					height: 208rpx;
					background: #FFF5E5;
					filter: blur(50px);
					position: absolute;
					top: -80rpx;
					left: -30rpx;
				}

				&-title {
					position: relative;
					z-index: 1;
				}
			}
		}

	}
</style>